package org.xxpay.pay.channel.alizftpay;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import org.xxpay.pay.channel.alizftpay.UserService;
import org.xxpay.pay.channel.alizftpay.UserServiceImpl;
public class test {
        public static void main(String[] args) {
            // 创建被代理对象
            UserService userService = (UserService) new UserServiceImpl();
            // 创建 InvocationHandler接口 对象
            InvocationHandler handler = new UserInvocationHandler(userService);
            // 创建动态代理对象
            UserService proxy = (UserService) Proxy.newProxyInstance(
                    userService.getClass().getClassLoader(),
                    userService.getClass().getInterfaces(),
                    handler);
            // 通过代理对象调用目标方法
            proxy.sayHelloWord();
        }
}
